public class Demo14 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = Thread.currentThread();
        System.out.println(t.getName());

        Thread t2 = new Thread(() -> {
            try {
                t.join();
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            System.out.println("t2结束");
        });
        t2.start();

        for (int i = 0; i < 5; i++) {
            Thread.sleep(1000);
        }

        System.out.println("main线程结束");
    }
}
